namespace ClassyBlog.Infrastructure.Specs.Unit
{
    using System.Web.Routing;

    using Machine.Specifications;

    using Infrastructure;
    using Web;

    [Subject(typeof(ArchivedDatesConstraint))]
    public class when_matching_with_valid_date
    {
        static ArchivedDatesConstraint constraint;
        static bool matched;

        Establish context = () => constraint = new ArchivedDatesConstraint();

        Because of = () =>
            matched = constraint.Match(
            null,
            null,
            "archiveDate",
            new RouteValueDictionary
                {
                    { ArchivedDates.YearParameterName, 2001 },
                    { ArchivedDates.MonthParameterName, 4 },
                    { ArchivedDates.DayParameterName, 30 }
                },
            RouteDirection.IncomingRequest);

        It should_match = () => matched.ShouldBeTrue();
    }

    [Subject(typeof(ArchivedDatesConstraint))]
    public class when_matching_with_invalid_date
    {
        static ArchivedDatesConstraint constraint;
        static bool matched;

        Establish context = () =>
            constraint = new ArchivedDatesConstraint();

        Because of = () => matched =
            constraint.Match(
            null,
            null,
            "archiveDate",
            new RouteValueDictionary
                {
                    { ArchivedDates.YearParameterName, 2001 },
                    { ArchivedDates.MonthParameterName, 4 },
                    { ArchivedDates.DayParameterName, 32 }
                },
            RouteDirection.IncomingRequest);

        It should_not_match = () => matched.ShouldBeFalse();
    }
}